/*
 * @Author: szx
 * @Date: 2022-02-25 13:10:18
 * @LastEditTime: 2022-02-25 13:13:14
 * @Description:
 * @FilePath: \leetcode\1000-1099\1013\1013.js
 */
/**
 * @param {number[]} arr
 * @return {boolean}
 */
var canThreePartsEqualSum = function (arr) {
    let sum = arr.reduce((a, b) => a + b, 0);
    if (sum % 3 != 0) return false;
    sum = Math.floor(sum / 3);
    let tmp = 0;
    let group = 0;
    for (let a of arr) {
        tmp += a;
        if (tmp > sum) return false;
        else if (tmp == sum) {
            tmp = 0;
            group++;
        }
    }
    if (group == 3) return true;
    return false;
};
